<div>
    <div class="row">
        <div class="col-md-8 offset-md-2">
            <h2 *ngIf="account">Password for [<b>{{account.login}}</b>]</h2>

            <div class="alert alert-success" *ngIf="success">
                <strong>Password changed!</strong>
            </div>
            <div class="alert alert-danger" *ngIf="error" >
                <strong>An error has occurred!</strong> The password could not be changed.
            </div>

            <div class="alert alert-danger" *ngIf="doNotMatch">
                The password and its confirmation do not match!
            </div>

            <form name="form" role="form" (ngSubmit)="changePassword()" #passwordForm="ngForm">

                <div class="form-group">
                    <label class="form-control-label" for="password">New password</label>
                    <input type="password" class="form-control" id="password" name="password" #passwordInput="ngModel"
                    placeholder="New password"
                           [(ngModel)]="password" minlength=4 maxlength=50 required>
                    <div *ngIf="passwordInput.dirty && passwordInput.invalid">
                        <small class="form-text text-danger"
                           *ngIf="passwordInput.errors.required">
                            Your password is required.
                        </small>
                        <small class="form-text text-danger"
                           *ngIf="passwordInput.errors.minlength">
                            Your password is required to be at least 4 characters.
                        </small>
                        <small class="form-text text-danger"
                           *ngIf="passwordInput.errors.maxlength">
                            Your password cannot be longer than 50 characters.
                        </small>
                    </div>
                    <jhi-password-strength-bar [passwordToCheck]="password"></jhi-password-strength-bar>
                </div>
                <div class="form-group">
                    <label class="form-control-label" for="confirmPassword">New password confirmation</label>
                    <input type="password" class="form-control" id="confirmPassword" name="confirmPassword" #confirmPasswordInput="ngModel"
                    placeholder="Confirm the new password"
                           [(ngModel)]="confirmPassword" minlength=4 maxlength=50 required>
                    <div *ngIf="confirmPasswordInput.dirty && confirmPasswordInput.invalid">
                        <small class="form-text text-danger"
                           *ngIf="confirmPasswordInput.errors.required">
                            Your confirmation password is required.
                        </small>
                        <small class="form-text text-danger"
                           *ngIf="confirmPasswordInput.errors.minlength">
                            Your confirmation password is required to be at least 4 characters.
                        </small>
                        <small class="form-text text-danger"
                           *ngIf="confirmPasswordInput.errors.maxlength">
                            Your confirmation password cannot be longer than 50 characters.
                        </small>
                    </div>
                </div>

                <button type="submit" [disabled]="passwordForm.form.invalid" class="btn btn-primary">Save</button>
            </form>
        </div>
    </div>
</div>
